## EAVS

## Loading packages
library(fixest)
library(haven)

## Loading data
eavs_ads = read_stata("eavs_ads.dta")
eavs_ads_border = read_stata("eavs_ads_border.dta")

## All Counties
## Table 2, odd columns (1, 3, 5, 7) in order
summary(feols(turnout ~ ads_sept | county_fips + state_election,
              data = eavs_ads, weights = eavs_ads$reg,
              cluster = ~ county_fips + dma_election))

summary(feols(pct_early ~ ads_sept | county_fips + state_election,
              data = eavs_ads, weights = eavs_ads$reg,
              cluster = ~ county_fips + dma_election))

summary(feols(pct_abs ~ ads_sept | county_fips + state_election,
              data = eavs_ads, weights = eavs_ads$reg,
              cluster = ~ county_fips + dma_election))

summary(feols(pct_eday ~ ads_sept | county_fips + state_election,
              data = eavs_ads, weights = eavs_ads$reg,
              cluster = ~ county_fips + dma_election))

## Table A6, odd columns (1, 3, 5, 7) in order
summary(feols(turnout ~ ads_lead | county_fips + state_election,
              data = eavs_ads, weights = eavs_ads$reg,
              cluster = ~ county_fips + dma_election))

summary(feols(pct_early ~ ads_lead | county_fips + state_election,
              data = eavs_ads, weights = eavs_ads$reg,
              cluster = ~ county_fips + dma_election))

summary(feols(pct_abs ~ ads_lead | county_fips + state_election,
              data = eavs_ads, weights = eavs_ads$reg,
              cluster = ~ county_fips + dma_election))

summary(feols(pct_eday ~ ads_lead | county_fips + state_election,
              data = eavs_ads, weights = eavs_ads$reg,
              cluster = ~ county_fips + dma_election))

## Border Counties
## Table 2, even columns (2, 4, 6, 8) in order
summary(feols(turnout ~ ads_sept | county_fips + border_pair_election,
              data = eavs_ads_border, weights = eavs_ads_border$reg,
              cluster = ~ county_fips + dma_border_election))

summary(feols(pct_early ~ ads_sept | county_fips + border_pair_election,
              data = eavs_ads_border, weights = eavs_ads_border$reg,
              cluster = ~ county_fips + dma_border_election))

summary(feols(pct_abs ~ ads_sept | county_fips + border_pair_election,
              data = eavs_ads_border, weights = eavs_ads_border$reg,
              cluster = ~ county_fips + dma_border_election))

summary(feols(pct_eday ~ ads_sept | county_fips + border_pair_election,
              data = eavs_ads_border, weights = eavs_ads_border$reg,
              cluster = ~ county_fips + dma_border_election))

## Table A6, even columns (2, 4, 6, 8) in order
summary(feols(turnout ~ ads_lead | county_fips + border_pair_election,
              data = eavs_ads_border, weights = eavs_ads_border$reg,
              cluster = ~ county_fips + dma_border_election))

summary(feols(pct_early ~ ads_lead | county_fips + border_pair_election,
              data = eavs_ads_border, weights = eavs_ads_border$reg,
              cluster = ~ county_fips + dma_border_election))

summary(feols(pct_abs ~ ads_lead | county_fips + border_pair_election,
              data = eavs_ads_border, weights = eavs_ads_border$reg,
              cluster = ~ county_fips + dma_border_election))

summary(feols(pct_eday ~ ads_lead | county_fips + border_pair_election,
              data = eavs_ads_border, weights = eavs_ads_border$reg,
              cluster = ~ county_fips + dma_border_election))
